using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using DAL;
using BUS;
using Utility;
public partial class Admin_Themhinhanh : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        //try
        //{
        int id = int.Parse(Request.QueryString["id"]);
        // Get the HttpFileCollection
        HttpFileCollection hfc = Request.Files;
        for (int i = 0; i < hfc.Count; i++)
        {
            HttpPostedFile hpf = hfc[i];
            if (hpf.ContentLength > 0)
            {
                hpf.SaveAs(Server.MapPath("~/Hinhanh/") + "\\" +
                System.IO.Path.GetFileName(hpf.FileName));

                System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/Hinhanh/" + hpf.FileName));
                ImageUtility.MakeThumbnailPhoto(img, 100, 100, Server.MapPath("~/Hinhanh/Hinh/"), hpf.FileName);

                tbHinhsanpham hsp = new tbHinhsanpham();
                hsp.Masp = id;
                hsp.Tenhinh = hpf.FileName.ToString();
                tbHinhsanphamBUS.Insert(hsp);
                Response.Write("<b>File: </b>" + hpf.FileName + "  <b>Size:</b> " +
                    hpf.ContentLength + "  <b>Type:</b> " + hpf.ContentType + " Uploaded Successfully <br/>");
            }

        }
        Response.Redirect("Danhsachsanpham.aspx");
    }
}
